package org.karelun.gef.commands;

import org.karelun.gef.helper.ConstantMessages;
import org.karelun.gef.model.Node;

public class RenameNodeCommand extends AbstractCommand {

    private Node node;

    private String newName;

    private String oldName;
    
    public void setName(String name) {
        this.newName = name;
    }

    public void setNode(Node node) {
        this.node = node;
    }
    
    public void execute() {
        oldName = node.getText();
        node.setText(newName);
    }

    public void redo() {
        node.setText(newName);
    }

    public void undo() {
        node.setText(oldName);
    }

    public String getLabel() {
        return ConstantMessages.RenameNodeCommand_Label_Text;
    }
}